package com.xuzz.study.springbootdemo.runner;

import com.xuzz.study.springbootdemo.event.DataLoadedEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

@Component
public class DataLoader implements CommandLineRunner {

    @Autowired
    ApplicationEventPublisher applicationEventPublisher;

    @Override
    public void run(String... args) throws Exception {
        System.out.println("data loader runner ....");

        applicationEventPublisher.publishEvent(new DataLoadedEvent(this));
    }
}
